home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_206 / stereodemo / sources / window.asm < prev    next >
Assembly Source File  |  1992-05-06  |  6KB  |  282 lines

  1.     INCLUDE "include:exec/types.i"
  2.     INCLUDE    "Stereo.i"
  3.  
  4.     XREF    _AbsExecBase
  5.     XREF    _LVOOpenWindow
  6.     XREF    _LVOCloseWindow
  7.     XREF    _LVOOpenLibrary
  8.     XREF    _LVOCloseLibrary
  9.     XREF    _LVOAllocMem
  10.     XREF    _LVOFreeMem
  11.     XREF    _LVODelay
  12.     XREF    _LVOMove
  13.     XREF    _LVODraw
  14.     XREF    _LVOSetAPen
  15.     XREF    _LVOGetPrefs
  16.     XREF    _LVOGetMsg
  17.     XREF    _LVOWindowToBack
  18.     XREF    _LVOText
  19.  
  20. CLEAR_PUBLIC    EQU    MEMF_CHIP!MEMF_CLEAR
  21. MyFlag    EQU    SMART_REFRESH!WINDOWDEPTH!WINDOWDRAG
  22.  
  23. MLP1    EQU    33
  24. SWidth    EQU    240
  25. FullH    EQU    100
  26. Begin:    move.l    a6,-(a7)
  27.     move.l    a7,InitSP
  28.     bsr    LibsOpen
  29.     bsr    Prefs
  30.     bsr    OpenNew
  31.     bsr    DoGraphs
  32.     bsr    CloseNew
  33.     bsr    CloseLibs
  34. Term:    move.l    InitSP,a7
  35.     move.l    (a7)+,a6
  36.     rts
  37. Prefs:
  38.     move.l    a6,-(a7)
  39.     move.l    #pf_SIZEOF,d0
  40.     bsr    StructureAlloc        ;Make space for preferences
  41.     move.l    IntuitionLibrary,a6
  42.     move.l    d0,a0            ;Point to space
  43.     move.l    a0,-(a7)
  44.     move.l    #pf_SIZEOF,d0        ;Get all of them
  45.     jsr    _LVOGetPrefs(a6)
  46.     move.l    (a7)+,a1
  47.     move.b    pf_LaceWB(a1),d0    ;Get lace status
  48.     cmp.b    #1,d0            ;See if interlace set
  49.     bne.s    NoInter
  50.     move.w    #FullH,d0
  51.     asl.w    #1,d0            ;Double for interlace
  52.     move.w    d0,SHeight
  53. NoInter:
  54.     move.l    #pf_SIZEOF,d0
  55.     bsr    StructFree
  56.     move.l    (a7)+,a6
  57.     rts
  58. InitNewWindow:
  59.     move.l    MyNewWindow,a2
  60.     move.w    #SWidth,nw_Width(a2)
  61.     move.w    SHeight,d0
  62.     lsl.w    #1,d0
  63.     sub.w    #17,d0
  64.     move.w    d0,nw_Height(a2)
  65.     move.w    #8,nw_LeftEdge(a2)
  66.     move.w    #16,nw_TopEdge(a2)
  67.     move.b    #1,nw_DetailPen(a2)    ;Black
  68.     move.b    #0,nw_BlockPen(a2)    ;White
  69.     move.l    #MyFlag,nw_Flags(a2)
  70.     move.w    #SWidth,nw_MinWidth(a2)
  71.     move.w    d0,nw_MinHeight(a2)
  72.     move.w    #SWidth,nw_MaxWidth(a2)
  73.     move.w    d0,nw_MaxHeight(a2)
  74.     move.w    #WBENCHSCREEN,nw_Type(a2)
  75.     rts
  76. OpenNew:
  77.     move.l    #nw_SIZE,d0
  78.     bsr    StructureAlloc
  79.     move.l    d0,a2
  80.     bne.s    SucAll
  81.     bra    TotFail    ;Can't display if not to this point.
  82. SucAll:    move.l    a2,MyNewWindow
  83.     bsr.s    InitNewWindow    ;Initialize new window structure
  84.     move.l    MyNewWindow,a0
  85.     movea.l    IntuitionLibrary,a6    ;a6 established by IntuOpen
  86.     jsr    _LVOOpenWindow(a6)  ;Open the new window.
  87.     move.l    d0,MyWindow    ;Pointer to window structure for new window
  88. TotFail:
  89.     rts
  90. CloseNew:
  91.     move.l    a6,-(a7)
  92.     movea.l    MyWindow,a0
  93.     movea.l    IntuitionLibrary,a6
  94.     jsr    _LVOCloseWindow(a6)
  95.     move.l    _AbsExecBase,a6
  96.     move.l    MyNewWindow,a1
  97.     move.l    #nw_SIZE,d0
  98.     bsr    StructFree
  99.     move.l    #0,MyNewWindow
  100.     move.l    (a7)+,a6
  101.     rts
  102. StructureAlloc:
  103.     move.l    a6,-(a7)    ;Save a6 (intution library base)
  104.     move.l    _AbsExecBase,a6    ;Exec functions coming up
  105.     move.l    #CLEAR_PUBLIC,d1    ;Public memory
  106.     jsr    _LVOAllocMem(a6)
  107.     move.l    (a7)+,a6    ;Recover a6
  108.     rts
  109. StructFree:
  110.     move.l    a6,-(a7)
  111.     move.l    _AbsExecBase,a6
  112.     move.l    a1,d1
  113.     beq.s    IsFree
  114.     jsr    _LVOFreeMem(a6)
  115. IsFree:    move.l    (a7)+,a6
  116.     rts
  117. *OpenLib opens the library whose name is pointed to by a1.  The library
  118. *base address is returned in d0.  a6 is destroyed.
  119. OpenLib:
  120.     move.l    #MLP1,d0        ;Version 33 or later
  121.     movea.l    _AbsExecBase,a6
  122.     jsr    _LVOOpenLibrary(a6)    ;Find Library base.
  123.     rts                ;Library base returned in d0
  124. LibsOpen:
  125. *Now open intuition    
  126. IntuOpen:
  127.     move.l    #IntuitionName,a1    ;Request intuition library.
  128.     bsr.s    OpenLib
  129.     move.l    d0,IntuitionLibrary
  130.     beq    TotFail
  131. GraphicsOpen:
  132. * Open the graphics library
  133.     move.l    #GraphicsName,a1     ;Request graphics library.
  134.     bsr.s    OpenLib
  135.     move.l    d0,GraphicsLibrary    ;Save pointer
  136.     beq    TotFail
  137. GraphOpen:
  138.     move.l    #DosName,a1
  139.     bsr.s    OpenLib
  140.     move.l    d0,DosLibrary
  141.     beq    TotFail
  142.     rts
  143. CloseLibs:
  144.     move.l    _AbsExecBase,a6        ;Be certain we have exec library
  145.     move.l    DosLibrary,a1
  146.     bsr    CloseLib
  147.     move.l    GraphicsLibrary,a1
  148.     bsr    CloseLib        ;Close graphics library
  149.     move.l    IntuitionLibrary,a1
  150.     bsr    CloseLib        ;Close intuition library
  151.     rts
  152. CloseLib:
  153.     move.l    a1,d0
  154.     beq.s    NotOpen
  155.     jsr    _LVOCloseLibrary(a6)
  156. NotOpen:
  157.     rts
  158. DoGraphs:
  159.     move.l    a6,-(a7)
  160.     move.l    GraphicsLibrary,a6
  161.     move.l    MyWindow,a1
  162.     move.l    wd_RPort(a1),a1    ;Get rasterport
  163.     move.l    a1,MyRP        ;Save raster port
  164.     move.l    #0,d0
  165.     jsr    _LVOSetAPen(a6)    ;Set back to black
  166.     move.l    #1,d1        ;Start 1 below top
  167.     move.l    #20,d3
  168.     move.l    #1,d4
  169.     bsr.s    ClrLin
  170.     move.l    MyRP,a1
  171.     move.l    #1,d0        ;Set Black
  172.     jsr    _LVOSetAPen(a6)
  173.     move.l    MyRP,a1
  174.     move.l    #0,d0
  175.     move.l    d0,d1
  176.     jsr    _LVOMove(a6)
  177.     move.l    MyRP,a1
  178.     move.l    #0,d1
  179.     move.l    #SWidth-1,d0
  180.     jsr    _LVODraw(a6)
  181.     move.l    MyRP,a1
  182.     move.l    #SWidth-1,d0
  183.     move.w    SHeight,d1
  184.     subq.w    #1,d1
  185.     ext.l    d1
  186.     jsr    _LVODraw(a6)
  187.     move.l    MyRP,a1
  188.     move.l    #0,d0
  189.     move.w    SHeight,d1
  190.     subq.w    #1,d1
  191.     ext.l    d1
  192.     jsr    _LVODraw(a6)
  193.     move.l    MyRP,a1
  194.     move.l    #0,d0
  195.     move.l    d0,d1
  196.     jsr    _LVODraw(a6)
  197.     move.l    MyRP,a1
  198.     move.l    #5,d0
  199.     move.l    #16,d1
  200.     jsr    _LVOMove(a6)
  201.     move.l    MyRP,a1
  202.     lea    String,a0
  203.     lea    StrEnd,a2
  204.     sub.l    a0,a2
  205.     move.l    a2,d0
  206.     jsr    _LVOText(a6)
  207.     move.l    #55,d5        ;60 0.4 s delays
  208.     bsr    DoDelay
  209.     move.l    MyRP,a1
  210.     move.l    #0,d2
  211.     move.w    SHeight,d3
  212.     subq.w    #2,d3
  213.     ext.l    d3
  214. DoLine:    move.l    #0,d0
  215.     move.l    #10,d1
  216.     movem.l    d0-d1/a1,-(a7)
  217.     jsr    _LVOMove(a6)
  218.     movem.l    (a7)+,d0-d1/a1
  219.     move.l    d2,d0
  220.     move.l    d3,d1
  221.     movem.l    d0-d1/a1,-(a7)
  222.     jsr    _LVODraw(a6)
  223.     move.l    #1,d5
  224.     bsr    DoDelay
  225.     movem.l    (a7)+,d0-d1/a1
  226.     addq.l    #8,d2
  227.     cmp.l    #SWidth-4,d2
  228.     blt.s    DoLine
  229.     move.l    (a7)+,a6
  230.     move.l    #280,d5
  231.     bsr.s    DoDelay
  232.     rts
  233. DoDelay:
  234.     movem.l    d1/a6,-(a7)
  235.     move.l    DosLibrary,a6
  236. SrtDel:    move.l    #20,d1        ;Allow 1/2 s per loop
  237.     jsr    _LVODelay(a6)
  238.     subq.l    #1,d5        ;Count down outer loop
  239.     bne.s    SrtDel
  240.     movem.l    (a7)+,d1/a6
  241.     rts
  242. ClrLin:    movem.l    d1/a1,-(a7)
  243.     move.l    d4,d0
  244.     jsr    _LVOMove(a6)
  245.     movem.l    (a7)+,d1/a1
  246.     movem.l    d1/a1,-(a7)
  247.     move.l    #SWidth-2,d0
  248.     jsr    _LVODraw(a6)
  249.     movem.l    (a7)+,d1/a1
  250.     addq.l    #1,d1
  251.     subq.l    #1,d3
  252.     bne.s    ClrLin
  253.     rts
  254.  
  255.     dseg
  256.  
  257. InitSP:    dc.l    0
  258. MyRP:    dc.l    0
  259. MyNewWindow:
  260.     dc.l    0
  261. MyWindow:
  262.     dc.l    0
  263. IntuitionLibrary:
  264.     dc.l    0
  265. GraphicsLibrary:
  266.     dc.l    0
  267. DosLibrary:
  268.     dc.l    0
  269. SHeight:
  270.     dc.w    100        ;Assume 100 for non-interlace
  271. IntuitionName:
  272.     dc.b    'intuition.library',0
  273. GraphicsName:
  274.     dc.b    'graphics.library',0
  275. DosName:
  276.     dc.b    'dos.library',0
  277.  
  278. String:    dc.b    '   ',$7f,'     ',$7f,'  NO CLI'
  279. StrEnd:    dc.b    0
  280.     END
  281.  
  282.